#pragma once

#include "Defines.h"
#include "Visual.h"

class Animation
{
public:
	Animation(void);
	Animation(VisualPack* visual);
	~Animation(void);
	void Update(uint16 diff);
	inline void SetVisual(uint8 visual_id) { m_currentVisual = visual_id; }
	inline void SetVisualPack(VisualPack* visual) { m_visualPack = visual; }
	inline void SetAnimation(uint16 animation_id) { m_currentAnimation = animation_id; }
	inline void SetDelay(uint16 delay) { m_delay = delay; }
	inline uint16 GetCurrentFrame() const { return m_currentFrame; }

	inline void Pause(bool pause = true) { m_paused = pause; }
	inline void Start() { m_currentFrame = 0; m_diff = 0; Pause(false); }

	const Rect& GetRect();
	inline VisualPack* GetVisualPack() const { return m_visualPack; }
	inline uint16 GetCurrentVisual() const { return m_currentVisual; }
	inline const sf::Image* GetSpriteSheet() const { assert(m_visualPack); return m_visualPack->GetVisual(m_currentVisual)->GetImage(); }
private:
	bool   m_paused;						//animations is paused?
	uint16 m_diff;							//time passed
	uint16 m_delay;							//delay between frames
	uint16  m_currentAnimation;				//Up,down,left,right,etc
	uint16 m_currentVisual;					//attack,move,etc
	uint16 m_currentFrame;					//current frame in the animation
	VisualPack* m_visualPack;				//visuals used by animation..don't deallocate it.. you don't own it!
	Rect m_rect;
};
